Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

176
Vistas
getOpenSessions() giving empty [ ] value

I am trying save the sessions in Set allSession , but the getOpenSessions() method creating an empty array. My code looks like -

@OnOpen
public void onOpen(Session session){
    System.out.println(session.getId() + " has opened a connection");
    System.out.println(" Session: "+session.getOpenSessions());
    try {
        session.getBasicRemote().sendText("Connection Established");
    } catch (IOException ex) {
        ex.printStackTrace();
    }
}

So, It's giving me an result -

1 has opened a connection

Session []

Can anyone suggest what is the exact problem here?

over 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

Sorry for the delayed answer. The bug was tomcat version 8.0. Tomcat 7 is more stable. I am using this from 3,4 months but session related issue is coming. Hope this information will help you.

over 4 years ago · Santiago Trujillo Denunciar

0

i got the same problem...but when i used the method in the @onMessage annotation method ..it works fine...the set is showing the elements...

over 4 years ago · Santiago Trujillo Denunciar

0

this worked!

    @OnMessage
    public String echo(String msg) throws IOException {
   
        Set<Session> set1 =  wsSession.getOpenSessions();
        
        System.out.println("set:  "+set1);
        
         Iterator<Session> iter = set1.iterator();
         
         while(iter.hasNext()) {
             
             
               System.out.println("entered inside while");
               
         }
    }
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda